import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 牛客网: 首页 > 试题广场 > 电话号码
 * <a href="https://www.nowcoder.com/questionTerminal/ceb89f19187b4de3997d9cdef2d551e8">...</a>
 * User: DELL
 * Date: 2023-05-14
 * Time: 23:17
 */
public class Main {
    /**
     * 解题思路:
     * 本题较为简单,总体就是先将原字符串按照要求处理成电话号码,
     * 之后将电话号码排序,排序后输出的时候和前一个号码进行比对,
     * 进行去重即可.
     * @param args
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] tel = new String[n];
            for (int i = 0; i < n; i++) {
                String temp = scanner.next();
                tel[i] = process(temp);
            }
            Arrays.sort(tel);
            System.out.println(tel[0]);
            for (int i = 1; i < tel.length; i++) {
                if (!tel[i-1].equals(tel[i])) {
                    System.out.println(tel[i]);
                }
            }
            //每一组之间以换行相隔
            System.out.println();
        }
    }

    /**
     * 将字符串处理成其对应的号码
     * @param tel
     * @return
     */
    private static String process(String tel) {
        StringBuffer res = new StringBuffer();
        //电话号码仅由连字符“-”、数字和大写字母组成
        for (char ch : tel.toCharArray()) {
            if (res.length() == 3) {
                res.append('-');
            }
            if (ch >= '0' && ch <= '9') {
                res.append(ch);
            } else if (ch >= 'A' && ch <= 'Z') {
                switch (ch) {
                    case 'A': case 'B': case 'C':
                        res.append('2');
                        break;
                    case 'D': case 'E': case 'F':
                        res.append('3');
                        break;
                    case 'G': case 'H': case 'I':
                        res.append('4');
                        break;
                    case 'J': case 'K': case 'L':
                        res.append('5');
                        break;
                    case 'M': case 'N': case 'O':
                        res.append('6');
                        break;
                    case 'P': case 'Q': case 'R': case 'S':
                        res.append('7');
                        break;
                    case 'T': case 'U': case 'V':
                        res.append('8');
                        break;
                    case 'W': case 'X': case 'Y': case 'Z':
                        res.append('9');
                        break;
                }
            }
        }
        return res.toString();
    }
}
